package com.bs.qxglmanager.controller;

import com.bs.qxglmanager.entity.User;
import com.bs.qxglmanager.service.UserService;
import com.bs.qxglmanager.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 小姚
 * @pakeageName:com.bs.qxglmanager.controller
 * @ClassName:UserController
 * @Descirption:
 * @data 2023/2/22 13:29
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService uservice;
    //查询所有用户
    @GetMapping("/userGetAll")
    public Result usergetAll(){
        List<User> user=uservice.usergetAll();
        return Result.success(user);
    }

    //用户添加
    @PostMapping("/userAdd")
    public Result userAdd(User user){
        uservice.userAdd(user);
        return Result.success("成功");
    }

    //用户修改
    @PutMapping("/userUpdate")
    public Result userUpdate(User user){
        uservice.userUpdate(user);
       return Result.success();
    }

    //用户删除
    @DeleteMapping("userDel")
    public Result userDel(String uid){
        uservice.userDel(uid);
        return Result.success();
    }
}
